﻿<Window x:Class="WAPA.Client.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:WAPA.Client"
        xmlns:wapa="clr-namespace:WAPA.Framework;assembly=WAPA.Framework"
        Title="Windows Azure Performance Analyser" Width="800" Height="600"  WindowState="Maximized">
    <Window.Resources>
        <SolidColorBrush x:Key="azure" Color="#01BCE5"></SolidColorBrush>
        <Style TargetType="TextBlock">
            <Setter Property="Foreground" Value="{StaticResource ResourceKey=azure}"></Setter>
            <Setter Property="VerticalAlignment" Value="Center"></Setter>
            <Setter Property="HorizontalAlignment" Value="Right"></Setter>
            <Setter Property="FontWeight" Value="Normal" ></Setter>
            <Setter Property="Margin" Value="10,7,10,7" ></Setter>
            <Setter Property="FontFamily" Value="Verdana" ></Setter>
            <Setter Property="FontSize" Value="11" ></Setter>
            <Setter Property="TextWrapping" Value="Wrap"></Setter>
        </Style>
        <Style TargetType="Button">
            <Setter Property="Background" Value="{StaticResource ResourceKey=azure}"></Setter>
            <Setter Property="Foreground" Value="White"></Setter>

            <Setter Property="BorderBrush" Value="Transparent"></Setter>
            <Setter Property="FontWeight" Value="Bold" ></Setter>
            <Setter Property="Margin" Value="10,7,10,7" ></Setter>
            <Setter Property="FontFamily" Value="Verdana" ></Setter>
            <Setter Property="FontSize" Value="12" ></Setter>
        </Style>
        <Style TargetType="local:ClickSelectTextBox">
            <Setter Property="Foreground" Value="{StaticResource ResourceKey=azure}"></Setter>
            <Setter Property="VerticalAlignment" Value="Center"></Setter>
            <Setter Property="HorizontalAlignment" Value="Right"></Setter>
            <Setter Property="FontWeight" Value="Bold" ></Setter>
            <Setter Property="Margin" Value="5,7,10,7" ></Setter>
            <Setter Property="Width" Value="250"></Setter>
        </Style>
        <Style TargetType="Border">
            <Setter Property="BorderBrush" Value="{StaticResource ResourceKey=azure}"></Setter>
            <Setter Property="BorderThickness" Value="5"></Setter>
            <Setter Property="CornerRadius" Value="10"></Setter>
            <Setter Property="Margin" Value="10,10,10,10"></Setter>
        </Style>
        <Style TargetType="Expander">
            <Setter Property="BorderBrush" Value="{StaticResource ResourceKey=azure}"></Setter>
            <Setter Property="BorderThickness" Value="1"></Setter>
            <Setter Property="Margin" Value="10,10,10,10"></Setter>
            <Setter Property="Background" Value="{StaticResource ResourceKey=azure}"></Setter>
            <Setter Property="Foreground" Value="White"></Setter>
            <Setter Property="FontWeight" Value="Bold"></Setter>
        </Style>
    </Window.Resources>
    <Grid x:Name="root">
        <Grid x:Name="managementGrid">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"></RowDefinition>
                    <RowDefinition></RowDefinition>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition MinWidth="200"></ColumnDefinition>
                    <ColumnDefinition Width="Auto"></ColumnDefinition>
                    <ColumnDefinition MinWidth="200"></ColumnDefinition>
                    <ColumnDefinition Width="Auto"></ColumnDefinition>
                    <ColumnDefinition MinWidth="200"></ColumnDefinition>
                </Grid.ColumnDefinitions>
                <GridSplitter Background="Transparent" Grid.RowSpan="2" Grid.Column="1" Height="Auto" Width="8" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
                <GridSplitter Background="Transparent"  Grid.RowSpan="2" Grid.Column="3" Height="Auto" Width="8" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />

                <TextBlock HorizontalAlignment="Center" Margin="0,10,0,0">Commands</TextBlock>
                <TextBlock HorizontalAlignment="Center" Margin="0,10,0,0" Grid.Column="2">Operations</TextBlock>
                <TextBlock HorizontalAlignment="Center" Margin="0,10,0,0" Grid.Column="4">Output</TextBlock>
                <Border Grid.Row="1" Margin="5,5,0,5">
                    <ScrollViewer   HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto" Margin="0,0,3,0">
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"></RowDefinition>
                                <RowDefinition></RowDefinition>
                                <RowDefinition Height="Auto"></RowDefinition>
                            </Grid.RowDefinitions>
                            <Grid>
                                <Grid.RowDefinitions>
                                    <RowDefinition></RowDefinition>
                                    <RowDefinition></RowDefinition>
                                    <RowDefinition></RowDefinition>
                                </Grid.RowDefinitions>
                                <Expander Header="Setup topology" Height="Auto" >
                                    <Grid Grid.Row="1"  x:Name="RegionSelection" Background="White">
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="Auto"></RowDefinition>
                                            <RowDefinition Height="Auto"></RowDefinition>
                                            <RowDefinition></RowDefinition>
                                            <RowDefinition Height="Auto"></RowDefinition>
                                        </Grid.RowDefinitions>
                                        <TextBlock ToolTip="Selecte the regions in which you want to create a hosted service." HorizontalAlignment="Left">Select regions:</TextBlock>
                                        <Grid x:Name="locationsListBoxOverlay" Grid.Row="1"   Visibility="Hidden" Background="#DDFFFFFF" >
                                            <Rectangle Width="100" Height="100" HorizontalAlignment="Center" VerticalAlignment="Center">
                                                <Rectangle.Fill>
                                                    <VisualBrush TileMode="None">
                                                        <VisualBrush.Visual>
                                                            <Grid  Width="150" Height="150">
                                                                <Grid x:Name="radar">
                                                                    <Grid.LayoutTransform>
                                                                        <RotateTransform x:Name="tr2" CenterX="25" CenterY="25" Angle="0" />
                                                                    </Grid.LayoutTransform>
                                                                    <Grid.Resources>
                                                                        <Storyboard x:Key="spin">
                                                                            <DoubleAnimation x:Name="da" Storyboard.TargetName="tr2" Storyboard.TargetProperty="Angle" By="360" Duration="0:0:2"                                AutoReverse="False"                               RepeatBehavior="Forever" />
                                                                        </Storyboard>
                                                                    </Grid.Resources>
                                                                    <Grid.Background>
                                                                        <DrawingBrush>
                                                                            <DrawingBrush.Drawing>
                                                                                <GeometryDrawing>
                                                                                    <GeometryDrawing.Brush>
                                                                                        <RadialGradientBrush>
                                                                                            <GradientStop Color="#01BCE5" Offset="0.0" />
                                                                                            <GradientStop Color="Transparent" Offset="1.0" />
                                                                                        </RadialGradientBrush>
                                                                                    </GeometryDrawing.Brush>
                                                                                    <GeometryDrawing.Geometry>
                                                                                        <GeometryGroup>
                                                                                            <RectangleGeometry Rect="0,0,50,50" />
                                                                                            <RectangleGeometry Rect="50,50,50,50" />
                                                                                        </GeometryGroup>
                                                                                    </GeometryDrawing.Geometry>
                                                                                </GeometryDrawing>
                                                                            </DrawingBrush.Drawing>
                                                                        </DrawingBrush>
                                                                    </Grid.Background>
                                                                </Grid>
                                                                <TextBlock Foreground="Black">Loading regions</TextBlock>
                                                            </Grid>
                                                        </VisualBrush.Visual>
                                                    </VisualBrush>
                                                </Rectangle.Fill>
                                            </Rectangle>
                                        </Grid>
                                        <ListBox BorderThickness="0" Background="White" Grid.Row="1"   x:Name="locationsListBox" SelectionMode="Multiple" ItemsSource="{Binding Path=Locations}">
                                            <ListBox.ItemTemplate>
                                                <DataTemplate>
                                                    <TextBlock Height="25" Text="{Binding Name}"></TextBlock>
                                                </DataTemplate>
                                            </ListBox.ItemTemplate>
                                        </ListBox>

                                        <Button x:Name="setupTopologyButton" Grid.Row="2" IsEnabled="false"  Background="Transparent" HorizontalContentAlignment="Stretch" BorderThickness="0"    Click="SetupTopology">
                                            <Grid>
                                                <Border Margin="0" BorderThickness="1" Background="{StaticResource ResourceKey=azure}" >
                                                    <Grid>
                                                        <TextBlock Foreground="White" HorizontalAlignment="Center">Setup topology</TextBlock>
                                                    </Grid>
                                                </Border>
                                            </Grid>
                                        </Button>
                                    </Grid>
                                </Expander>
                                <Expander x:Name="deployLoadTestServices" Height="Auto" Grid.Row="1" Header="Deploy services"  Expanded="FillHostedServices">
                                    <Grid Grid.Row="1" x:Name="deployLoadTestServicesConfiguration" Background="White">
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="Auto"></RowDefinition>
                                            <RowDefinition Height="Auto"></RowDefinition>
                                            <RowDefinition Height="Auto"></RowDefinition>
                                            <RowDefinition></RowDefinition>
                                        </Grid.RowDefinitions>
                                        <Grid Margin="0,0,5,0">
                                            <Grid.RowDefinitions>
                                                <RowDefinition Height="Auto"></RowDefinition>
                                                <RowDefinition Height="Auto"></RowDefinition>
                                                <RowDefinition Height="Auto"></RowDefinition>
                                            </Grid.RowDefinitions>
                                            <Grid.ColumnDefinitions>
                                                <ColumnDefinition></ColumnDefinition>
                                                <ColumnDefinition></ColumnDefinition>
                                            </Grid.ColumnDefinitions>

                                            <TextBlock>VM Size</TextBlock>
                                            <ComboBox VerticalContentAlignment="Center" VerticalAlignment="Center" x:Name="vmSizeDropDown" Background="Transparent" Grid.Column="1"  ItemsSource="{Binding Path=VmSizes}" SelectedIndex="0">
                                                <ComboBox.ItemTemplate>
                                                    <DataTemplate>
                                                        <TextBlock Text="{Binding}"></TextBlock>
                                                    </DataTemplate>
                                                </ComboBox.ItemTemplate>
                                            </ComboBox>
                                            <TextBlock Grid.Row="1" ToolTip="Enter the number of instances that monitor the queue">Instances</TextBlock>

                                            <ComboBox Grid.Row="1" Grid.Column="1" VerticalContentAlignment="Center" VerticalAlignment="Center" x:Name="noInstancesDropDown" Background="Transparent" SelectedIndex="0">
                                                <ComboBoxItem>1</ComboBoxItem>
                                                <ComboBoxItem>2</ComboBoxItem>
                                                <ComboBoxItem>3</ComboBoxItem>
                                                <ComboBoxItem>4</ComboBoxItem>
                                                <ComboBoxItem>5</ComboBoxItem>
                                                <ComboBoxItem>6</ComboBoxItem>
                                                <ComboBoxItem>7</ComboBoxItem>
                                                <ComboBoxItem>8</ComboBoxItem>
                                                <ComboBoxItem>9</ComboBoxItem>
                                                <ComboBoxItem>10</ComboBoxItem>
                                                <ComboBoxItem>11</ComboBoxItem>
                                                <ComboBoxItem>12</ComboBoxItem>
                                                <ComboBoxItem>13</ComboBoxItem>
                                                <ComboBoxItem>14</ComboBoxItem>
                                                <ComboBoxItem>15</ComboBoxItem>
                                                <ComboBoxItem>16</ComboBoxItem>
                                                <ComboBoxItem>17</ComboBoxItem>
                                                <ComboBoxItem>18</ComboBoxItem>
                                                <ComboBoxItem>19</ComboBoxItem>
                                                <ComboBoxItem>20</ComboBoxItem>
                                            </ComboBox>

                                            <TextBlock Grid.Row="2">Slot</TextBlock>
                                            <ComboBox Grid.Row="2" Grid.Column="1" VerticalAlignment="Center" VerticalContentAlignment="Center" x:Name="slotDropDown" Background="Transparent"  SelectedIndex="0">
                                                <ComboBoxItem>Staging</ComboBoxItem>
                                                <ComboBoxItem>Production</ComboBoxItem>
                                            </ComboBox>

                                        </Grid>

                                        <TextBlock Grid.Row="1"  HorizontalAlignment="Left" FontSize="12">Select hosted services to deploy packages to:</TextBlock>
                                        <Grid Grid.IsSharedSizeScope="True" Grid.Row="2">
                                            <Grid.RowDefinitions>
                                                <RowDefinition></RowDefinition>
                                                <RowDefinition></RowDefinition>
                                            </Grid.RowDefinitions>
                                            <Grid>
                                                <Grid.ColumnDefinitions>
                                                    <ColumnDefinition SharedSizeGroup="D"></ColumnDefinition>
                                                    <ColumnDefinition SharedSizeGroup="E"></ColumnDefinition>
                                                </Grid.ColumnDefinitions>

                                                <TextBlock HorizontalAlignment="Left">Service label</TextBlock>
                                                <TextBlock HorizontalAlignment="Left"  Grid.Column="1">Region</TextBlock>
                                            </Grid>
                                            <ListBox Grid.Row="1" MinHeight="30" BorderThickness="0" Background="White" HorizontalContentAlignment="Stretch"   x:Name="hostedServicesListBox" SelectionMode="Multiple" ItemsSource="{Binding Path=HostedServices}">
                                                <ListBox.ItemTemplate>
                                                    <DataTemplate>
                                                        <Grid VerticalAlignment="Top" Margin="3">
                                                            <Grid.ColumnDefinitions>
                                                                <ColumnDefinition SharedSizeGroup="D"></ColumnDefinition>
                                                                <ColumnDefinition SharedSizeGroup="E"></ColumnDefinition>
                                                            </Grid.ColumnDefinitions>


                                                            <TextBlock Foreground="Black" ToolTip="{Binding Path=ServiceName}" Text="{Binding Path=HostedServiceProperties.Label}"></TextBlock>
                                                            <TextBlock Foreground="Black"  Grid.Column="1" Text="{Binding Path=HostedServiceProperties.Location}"></TextBlock>
                                                            <TextBlock Foreground="Black" Grid.Column="1" Text="{Binding Path=HostedServiceProperties.AffinityGroup}"></TextBlock>
                                                        </Grid>
                                                    </DataTemplate>
                                                </ListBox.ItemTemplate>
                                            </ListBox>
                                            <!--<local:PendingOverlay Visibility="Visible" Background="AliceBlue" Width="100" Height="100"  x:Name="hostedServicesListBoxOverlay" OverlayText="Loading hosted services"></local:PendingOverlay>-->
                                            <Border Grid.Row="1" x:Name="hostedServicesListBoxOverlay" CornerRadius="0" BorderThickness="1" BorderBrush="Black" Width="150" Height="20">

                                                <Rectangle x:Name="progress" HorizontalAlignment="Left" Visibility="Visible" Width="10"
 VerticalAlignment="Stretch" 
  
  Fill="Blue" Opacity="0.6">
                                                    <Rectangle.Triggers>

                                                        <!-- Animates the rectangle's opacity. -->
                                                        <EventTrigger RoutedEvent="Rectangle.Loaded">
                                                            <BeginStoryboard>
                                                                <Storyboard>
                                                                    <DoubleAnimation
            Storyboard.TargetName="progress" 
            Storyboard.TargetProperty="Width"
            From="0" To="150" Duration="0:0:10" 
            AutoReverse="False"  />
                                                                </Storyboard>
                                                            </BeginStoryboard>
                                                        </EventTrigger>
                                                    </Rectangle.Triggers>
                                                </Rectangle>
                                            </Border>


                                        </Grid>


                                        <Button x:Name="deployCalculationServicesButton" IsEnabled="false"  Background="Transparent" HorizontalContentAlignment="Stretch" BorderThickness="0"    Grid.Row="3"  Click="DeployCalculationServices">
                                            <Grid>
                                                <Border Margin="0" BorderThickness="1" Background="{StaticResource ResourceKey=azure}" >
                                                    <Grid>
                                                        <TextBlock Foreground="White" HorizontalAlignment="Center">Deploy and run</TextBlock>
                                                    </Grid>
                                                </Border>
                                            </Grid>
                                        </Button>



                                    </Grid>
                                </Expander>
                                <Expander Height="Auto" Grid.Row="2" Header="Send tasks"  Expanded="FillDeployments">
                                    <Grid Grid.Row="1" x:Name="sendTasksConfiguration" Background="White">
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="Auto"></RowDefinition>
                                            <RowDefinition Height="Auto"></RowDefinition>
                                            <RowDefinition Height="Auto"></RowDefinition>
                                            <RowDefinition></RowDefinition>
                                        </Grid.RowDefinitions>
                                        <Grid Margin="0,0,5,0">
                                            <Grid.RowDefinitions>
                                                <RowDefinition Height="Auto"></RowDefinition>
                                                <RowDefinition Height="Auto"></RowDefinition>
                                                <RowDefinition Height="Auto"></RowDefinition>

                                            </Grid.RowDefinitions>
                                            <Grid.ColumnDefinitions>
                                                <ColumnDefinition></ColumnDefinition>
                                                <ColumnDefinition></ColumnDefinition>
                                            </Grid.ColumnDefinitions>
                                            <TextBlock ToolTip="Enter in millions of digits. 10 = 10^6 digits (10MB file output)">Precision</TextBlock>
                                            <TextBox VerticalAlignment="Center" Grid.Column="1" x:Name="precision">10</TextBox>

                                            <TextBlock Grid.Row="1" ToolTip="Enter repeat count for this task">Repeats</TextBlock>
                                            <TextBox Grid.Row="1" VerticalAlignment="Center" Grid.Column="1" x:Name="repeatCount">1</TextBox>

                                            <TextBlock Grid.Row="2" ToolTip="Enter repeat interval in seconds for this task">Interval</TextBlock>
                                            <TextBox Grid.Row="2" VerticalAlignment="Center" Grid.Column="1" x:Name="repeatInterval">3600</TextBox>

                                        </Grid>


                                        <TextBlock Grid.Row="1"  HorizontalAlignment="Left" FontSize="12">Select deployments to send task to:</TextBlock>
                                        <Grid Grid.IsSharedSizeScope="True" Grid.Row="2">
                                            <Grid.RowDefinitions>
                                                <RowDefinition></RowDefinition>
                                                <RowDefinition></RowDefinition>
                                            </Grid.RowDefinitions>
                                            <Grid>
                                                <Grid.ColumnDefinitions>
                                                    <ColumnDefinition SharedSizeGroup="F"></ColumnDefinition>
                                                    <ColumnDefinition SharedSizeGroup="G"></ColumnDefinition>
                                                </Grid.ColumnDefinitions>
                                                <TextBlock HorizontalAlignment="Left">Label</TextBlock>
                                                <TextBlock HorizontalAlignment="Left" Grid.Column="1">Slot</TextBlock>
                                            </Grid>
                                            <ListBox Grid.Row="1" MinHeight="30" BorderThickness="0" Background="White" HorizontalContentAlignment="Stretch"   x:Name="deploymentsListBox" SelectionMode="Multiple" ItemsSource="{Binding Path=Deployments}">
                                                <ListBox.ItemTemplate>
                                                    <DataTemplate>
                                                        <Grid VerticalAlignment="Top" >
                                                            <Grid.ColumnDefinitions>
                                                                <ColumnDefinition SharedSizeGroup="F"></ColumnDefinition>
                                                                <ColumnDefinition SharedSizeGroup="G"></ColumnDefinition>
                                                            </Grid.ColumnDefinitions>
                                                            <TextBlock Margin="3"  ToolTip="{Binding Path=Label}" Text="{Binding Path=Name}" ></TextBlock>
                                                            <TextBlock Margin="3"  Grid.Column="1" Text="{Binding Path=DeploymentSlot}"></TextBlock>

                                                        </Grid>
                                                    </DataTemplate>
                                                </ListBox.ItemTemplate>
                                            </ListBox>
                                            <Border Grid.Row="1" x:Name="deploymentsListBoxOverlay" CornerRadius="0" BorderThickness="1" BorderBrush="Black" Width="150" Height="20">

                                                <Rectangle x:Name="progressD" HorizontalAlignment="Left" Visibility="Visible" Width="10"
 VerticalAlignment="Stretch" 
  
  Fill="Blue" Opacity="0.6">
                                                    <Rectangle.Triggers>
                                                        <!-- Animates the rectangle's opacity. -->
                                                        <EventTrigger RoutedEvent="Rectangle.Loaded">
                                                            <BeginStoryboard>
                                                                <Storyboard>
                                                                    <DoubleAnimation
            Storyboard.TargetName="progressD" 
            Storyboard.TargetProperty="Width"
            From="0" To="150" Duration="0:0:10" 
            AutoReverse="False"  />
                                                                </Storyboard>
                                                            </BeginStoryboard>
                                                        </EventTrigger>
                                                    </Rectangle.Triggers>
                                                </Rectangle>
                                            </Border>
                                        </Grid>


                                        <Button x:Name="sendTasksButton" IsEnabled="false"  Background="Transparent" HorizontalContentAlignment="Stretch" BorderThickness="0"    Grid.Row="3"  Click="SendTasks">
                                            <Grid>
                                                <Border Margin="0" BorderThickness="1" Background="{StaticResource ResourceKey=azure}" >
                                                    <Grid>
                                                        <TextBlock Foreground="White" HorizontalAlignment="Center">Send</TextBlock>
                                                    </Grid>
                                                </Border>
                                            </Grid>
                                        </Button>



                                    </Grid>
                                </Expander>


                            </Grid>

                            <Border Height="0" VerticalAlignment="Bottom" Grid.Row="1" BorderThickness="1" x:Name="internetErrorBorder"  Margin="5" Background="Red" Visibility="Hidden" >
                                <Grid>
                                    <TextBlock Foreground="Yellow" HorizontalAlignment="Center">Internet connection error</TextBlock>
                                </Grid>
                            </Border>

                        </Grid>
                    </ScrollViewer>
                </Border>
                <Border Grid.Row="1" Grid.Column="2" Margin="0,5,0,5">
                    <ScrollViewer  HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" Margin="0,0,3,0">
                        <ListBox x:Name="pendingTasks" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch" Width="Auto" ItemsSource="{Binding Path=Operations}" BorderThickness="0" Margin="5">
                            <ListBox.ItemTemplate>
                                <DataTemplate>
                                    <Border Margin="0,1,0,0" HorizontalAlignment="Stretch"  x:Name="operation" >
                                        <Grid HorizontalAlignment="Stretch">
                                            <Grid.RowDefinitions>
                                                <RowDefinition></RowDefinition>
                                                <RowDefinition Height="Auto"></RowDefinition>
                                            </Grid.RowDefinitions>
                                            <Grid.ColumnDefinitions>
                                                <ColumnDefinition Width="24"></ColumnDefinition>
                                                <ColumnDefinition></ColumnDefinition>

                                            </Grid.ColumnDefinitions>
                                            <Ellipse Grid.RowSpan="2" Width="18" Height="18" VerticalAlignment="Center" HorizontalAlignment="Center" x:Name="statusShape" StrokeThickness="2"  Stroke="{StaticResource ResourceKey=azure}" Fill="White"></Ellipse>
                                            <TextBlock Grid.Column="1"  VerticalAlignment="Center" TextAlignment="Left"  Text="{Binding OperationDescription}"></TextBlock>

                                            <TextBlock Foreground="Yellow" Grid.Row="1" Grid.Column="1"  Visibility="Collapsed" x:Name="errorMessage" Text="{Binding ErrorMessage}"></TextBlock>
                                        </Grid>
                                    </Border>
                                    <DataTemplate.Triggers>
                                        <DataTrigger Binding="{Binding Path=Completed}" Value="true">
                                            <Setter TargetName="statusShape" Property="Fill" Value="LightGreen" />
                                        </DataTrigger>
                                        <DataTrigger Binding="{Binding Path=Status}" Value="Failed">
                                            <Setter TargetName="statusShape" Property="Fill" Value="Red" />
                                            <Setter TargetName="errorMessage" Property="Visibility" Value="Visible" />

                                        </DataTrigger>
                                    </DataTemplate.Triggers>

                                </DataTemplate>
                            </ListBox.ItemTemplate>
                        </ListBox>
                    </ScrollViewer>
                </Border>
                <Border Grid.Row="1" Grid.Column="4" Margin="0,5,5,5">
                    <ScrollViewer   HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto" Margin="0,0,3,0">
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"></RowDefinition>
                                <RowDefinition Height="Auto"></RowDefinition>
                                <RowDefinition Height="Auto"></RowDefinition>
                            </Grid.RowDefinitions>
                            <Expander Header="Registered instances">
                                <Grid Grid.IsSharedSizeScope="True" VerticalAlignment="Top">
                                    <Grid.RowDefinitions>
                                        <RowDefinition></RowDefinition>
                                        <RowDefinition></RowDefinition>
                                    </Grid.RowDefinitions>
                                    <Grid VerticalAlignment="Top" Background="White">
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition SharedSizeGroup="A"></ColumnDefinition>
                                            <ColumnDefinition SharedSizeGroup="B"></ColumnDefinition>
                                            <ColumnDefinition SharedSizeGroup="C"></ColumnDefinition>
                                        </Grid.ColumnDefinitions>
                                        <TextBlock  HorizontalAlignment="Left">Deployment Id</TextBlock>
                                        <TextBlock HorizontalAlignment="Left" Grid.Column="1" >Machine name</TextBlock>
                                        <TextBlock   HorizontalAlignment="Left" Grid.Column="2" >No. Cores</TextBlock>
                                    </Grid>
                                    <ListBox  Grid.Row="1" x:Name="registeredInstancesListBox" ItemsSource="{Binding Path=RegisteredInstances}">
                                        <ListBox.ItemTemplate>
                                            <DataTemplate>
                                                <Grid Margin="3,1,3,1">
                                                    <Grid Background="White">
                                                        <Grid.ColumnDefinitions>
                                                            <ColumnDefinition SharedSizeGroup="A"></ColumnDefinition>
                                                            <ColumnDefinition SharedSizeGroup="B"></ColumnDefinition>
                                                            <ColumnDefinition SharedSizeGroup="C"></ColumnDefinition>
                                                        </Grid.ColumnDefinitions>
                                                        <TextBlock Margin="3" Foreground="Black"  Text="{Binding Path=DeploymentId}"></TextBlock>
                                                        <TextBlock Margin="3"  Foreground="Black" Grid.Column="1" Text="{Binding Path=MachineName}"></TextBlock>
                                                        <TextBlock Margin="3"  Foreground="Black"  Grid.Column="2" Text="{Binding Path=ProcessorCount}"></TextBlock>
                                                    </Grid>
                                                </Grid>
                                            </DataTemplate>
                                        </ListBox.ItemTemplate>
                                    </ListBox>
                                </Grid>
                            </Expander>
                            <!--<Expander Grid.Row="1" Header="Pending tasks">
                                <ListBox x:Name="pendingTasksListBox" ItemsSource="{Binding Path=PendingTasks}"></ListBox>

                            </Expander>-->
                            <Expander Grid.Row="1" Header="Task reports">


                                <Grid Grid.IsSharedSizeScope="True">
                                    <Grid.RowDefinitions>
                                        <RowDefinition></RowDefinition>
                                        <RowDefinition></RowDefinition>
                                    </Grid.RowDefinitions>
                                    <Grid Background="White">
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition SharedSizeGroup="P"></ColumnDefinition>
                                            <ColumnDefinition SharedSizeGroup="Q"></ColumnDefinition>
                                            <ColumnDefinition SharedSizeGroup="R"></ColumnDefinition>
                                        </Grid.ColumnDefinitions>
                                        <TextBlock HorizontalAlignment="Left">Calculation</TextBlock>
                                        <TextBlock Grid.Column="1" HorizontalAlignment="Left">Transfer</TextBlock>
                                    </Grid>

                                    <ListBox Grid.Row="1" x:Name="reportsListBox" ItemsSource="{Binding Path=Reports}">
                                        <ListBox.ItemTemplate>
                                            <DataTemplate>
                                                <Expander ToolTip="{Binding Path=DeploymentId}" Header="{Binding Path=TaskId}">
                                                    <Grid Background="White">
                      
                                                        <Grid.ColumnDefinitions>
                                                            <ColumnDefinition SharedSizeGroup="P"></ColumnDefinition>
                                                            <ColumnDefinition SharedSizeGroup="Q"></ColumnDefinition>
                                                            <ColumnDefinition SharedSizeGroup="R"></ColumnDefinition>
                                                        </Grid.ColumnDefinitions>
                                                        <TextBlock Foreground="Black" Text="{Binding Path=TaskDurationTicks}"></TextBlock>
                                                        <TextBlock Foreground="Black"  Grid.Column="1" Text="{Binding Path=OutputTransferDurationTicks}"></TextBlock>
                                                        <TextBlock Foreground="Black"  Grid.Row="2" Text="{Binding Path=OutputSize}"></TextBlock>
                                                    
                                                    </Grid>
                                                </Expander>
                                            </DataTemplate>
                                        </ListBox.ItemTemplate>
                                    </ListBox>
                                </Grid>

                            </Expander>
                            <Expander Grid.Row="2" Header="Output blobs">
                                <ListBox x:Name="outputBlobsListBox" ItemsSource="{Binding Path=OutputBlobs}">
                                    <ListBox.ItemTemplate>
                                        <DataTemplate>

                                            <TextBlock Margin="3,1,3,1" Background="White" Foreground="Black" Text="{Binding Path=Uri.AbsolutePath}"></TextBlock>

                                        </DataTemplate>
                                    </ListBox.ItemTemplate>
                                </ListBox>
                            </Expander>
                        </Grid>
                    </ScrollViewer>

                </Border>
            </Grid>
            <!--<StackPanel VerticalAlignment="Center" HorizontalAlignment="Center">
                    <Button  Click="Setup">Test WAPA Service</Button>
                    <TextBlock x:Name="resultTextBlock"></TextBlock>
                    <ListBox x:Name="locationsListBox" ItemsSource="{Binding Path=Locations}">
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <TextBlock Text="{Binding Name}"></TextBlock>
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>
                   
                </StackPanel>-->

        </Grid>
        <Grid  x:Name="configOverlay" Background="#DFFFFFFF" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
            <Border  Background="White" HorizontalAlignment="Center" VerticalAlignment="Center">
                <Grid >
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition></ColumnDefinition>
                        <ColumnDefinition></ColumnDefinition>
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition></RowDefinition>
                        <RowDefinition></RowDefinition>
                        <RowDefinition></RowDefinition>
                        <RowDefinition></RowDefinition>
                        <RowDefinition></RowDefinition>
                        <RowDefinition></RowDefinition>
                        <RowDefinition></RowDefinition>
                    </Grid.RowDefinitions>
                    <TextBlock>Subscription id</TextBlock>
                    <TextBlock Grid.Row="1">Certificate thumbprint</TextBlock>
                    <TextBlock Grid.Row="2">Storage account name</TextBlock>
                    <TextBlock Grid.Row="3">Storage account access key</TextBlock>
                    <TextBlock Grid.Row="4">Certificate key password</TextBlock>
                    <TextBlock Grid.Row="5">Worker role config file</TextBlock>
                    <local:ClickSelectTextBox Grid.Column="1" Text="{Binding Path=SubscriptionId,Mode=TwoWay}"></local:ClickSelectTextBox>
                    <local:ClickSelectTextBox Grid.Column="1" Grid.Row="1"  Text="{Binding Path=CertificateThumbprint,Mode=TwoWay}"></local:ClickSelectTextBox>
                    <local:ClickSelectTextBox Grid.Column="1" Grid.Row="2" Text="{Binding Path=StorageAccountName,Mode=TwoWay}" >
                    </local:ClickSelectTextBox>
                    <local:ClickSelectTextBox Grid.Column="1" Grid.Row="3" Text="{Binding Path=AccessKey,Mode=TwoWay}" >
                    </local:ClickSelectTextBox>
                    <local:ClickSelectTextBox Grid.Column="1" Grid.Row="4" Text="{Binding Path=CertificatePrivateKeyPassword,Mode=TwoWay}" >
                    </local:ClickSelectTextBox>
                    <local:ClickSelectTextBox Grid.Column="1" Grid.Row="5" Text="{Binding Path=WorkerConfigFile,Mode=TwoWay}" >
                    </local:ClickSelectTextBox>
                    <StackPanel Orientation="Horizontal" Grid.Row="6" Grid.Column="1">
                        <Button Click="Start" >Ok</Button>
                        <Button  Click="Quit" >Quit</Button>
                    </StackPanel>

                    <!--ManagementContext.SubscriptionId = ConfigurationManager.AppSettings["SubscriptionId"];//"efb150a3-d5c2-420c-b8dd-57811042f801";
            ManagementContext.CertificateThumbprint = ConfigurationManager.AppSettings["CertificateThumbprint"];// "6FCC1FC9332C851EAAD8E1DE63DBA1C40433AC5F";
            ManagementContext.AccessKey = ConfigurationManager.AppSettings["AccessKey"]; 
            ManagementContext.StorageAccountName = ConfigurationManager.AppSettings["StorageAccountName"]; 
            ManagementContext.CertificatePrivateKeyPassword = ConfigurationManager.AppSettings["CertificatePrivateKeyPassword"];
            ManagementContext.WorkerConfig = File.ReadAllText(ConfigurationManager.AppSettings["WorkerConfigFile"]);-->

                </Grid >
            </Border>
        </Grid>
    </Grid>
</Window>
